package com.atguigu.jxc.controller;

import com.atguigu.jxc.domain.ServiceVO;
import com.atguigu.jxc.entity.Supplier;
import com.atguigu.jxc.service.SupplierService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @author 杨林
 * @create 2023-01-28 18:12 星期六
 * description:
 */
@RequestMapping("/supplier")
@RestController
public class SupplierController {

    @Autowired
    SupplierService supplierService;

    /**
     * 分页查询供应商
     * @param page
     * @param rows
     * @param supplierName
     * @return
     */
    @PostMapping("/list")
    public Map<String,Object> list(Integer page,
                                   Integer rows,
                                   String supplierName){

        return supplierService.list(page,rows,supplierName);
    }


    /**
     * 保存或修改供应商
     * @param supplier
     * @return
     */
    @PostMapping("/save")
    public ServiceVO saveOrUpdate(Supplier supplier){
        return supplierService.saveOrUpdate(supplier);
    }

    /**
     * 删除供应商
     * @param ids
     * @return
     */
    @PostMapping("/delete")
    public ServiceVO delete(String ids){

        return supplierService.delete(ids);
    }

    /**
     * 供应商下拉列表查询 (支持供应商名称模糊查询)
     * @return
     */
    @PostMapping("/getComboboxList")
    public List<Supplier> getComboboxList(String q){

        return supplierService.getComboboxList(q);
    }
}
